package com.boot.business.demo.service.imp;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.boot.business.demo.dao.UserJpaDao;
import com.boot.business.demo.entity.User;
import com.boot.business.demo.mdao.MUserDao;
import com.boot.business.demo.service.UserService;

/**
 * 
 * @ClassName UserServiceImpl
 * @author yinyong
 */
@Service
public class UserServiceImpl implements UserService {

	//	@Autowired
	//	private UserDao userDao;
	@Autowired
	private UserJpaDao userJpaDao;

	@Autowired //连接到UserDao Bean
	private MUserDao userDao;

	/**
	 * 
	 * @param map
	 * @return
	 */
	public Object getList(Map<String, Object> map) {
		return null;
	}

	/**
	 * 
	 * @param UserName
	 * @return
	 */
	@Override
	public User getUserByName(String username) {
		return userJpaDao.findByName(username);
	}
	@Override
	public List<User> showDao(String phone) {
		return userDao.get(phone);
	}
	@Override
	public String insert(String name, String phone) { //插入一条记录
		User user = new User();
		user.setUsername(name);
		user.setTelephone(phone);
		userDao.insert(user);
		return "Insert ( \""+name+"\", age"+phone+") OK!";
	}

	@Override
	public User getUserByTelephone(String telephone) {
		return userJpaDao.findByTelephone(telephone);
	}
}
